package com.jic.interaction.weChatCardAndOffers.model.vo.request;

import com.jic.interaction.weChatCardAndOffers.common.utils.JSONObject;
import com.jic.interaction.weChatCardAndOffers.model.entity.WxCardBaseInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author jackylian
 */
@Data
@ApiModel(description = "卡券实体类")
public abstract class WxCardRequest {

    @ApiModelProperty(notes = "基本的卡券数据")
    protected WxCardBaseInfoRequest m_baseInfo;

    protected JSONObject m_requestData;
    protected JSONObject m_data;
    @ApiModelProperty(notes = "团购券类型。")
    protected String m_cardType;

    public WxCardRequest() {
        m_baseInfo = new WxCardBaseInfoRequest();
        m_requestData = new JSONObject();
    }

    void init(String cardType) {
        m_cardType = cardType;
        JSONObject obj = new JSONObject();
        obj.put("card_type", m_cardType.toUpperCase());
        m_data = new JSONObject();
        m_data.put("base_info", m_baseInfo.m_data);
        obj.put(m_cardType.toLowerCase(), m_data);
        m_requestData.put("card", obj);
    }

    public JSONObject getJSONObject() {
        return m_requestData;
    }

    public String toJsonString() {
        return m_requestData.toString();
    }

    public String toString() {
        return toJsonString();
    }

    public WxCardBaseInfoRequest getBaseInfo() {
        return m_baseInfo;
    }

}
